require "luacalc"

--
-- Test script for the luacalc api.
-- TODO: add more; help welcome
--

function test(t, message)
   if assert(t) then
      print("Success: ", message)
   end
end

-- test undo/redo for pasting
luacalc.startpaste()
set(1, 1, 1)
set(1, 1, 3)
luacalc.endpaste()
luacalc.undo()
test(A1==nil, "copy/paste undo redo")
set(1, 1, 1)
set(2, 1, 1)
set(3, 1, 1)
set(4, 1, 1)
set(5, 1, "=SUM(A1:A4)")
test(A5==4, "sum function on A1:A4 == 4")


set(1, 1, "1")
set(2, 1, "=FIB(A1)")
print(getformula(2, 1), get(2,1), A2)
test(A1=="1", "fib(1)==1")

str = "hello + $x"
x = 7

print(string.gsub(str, "$x", x))